package com.hb.demo.controller;

import com.hb.commons.ResponseDto;
import com.hb.demo.entity.User;
import com.hb.demo.service.UserService;
import com.hb.util.ResultUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 *  多数据源测试
 * </p>
 *
 * @author 赵老板
 * @since 2021-08-15
 */
@RestController
public class UserController {

    protected final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @PostMapping("/user/add")
    public ResponseDto add(@RequestBody User user) {
        user.buildBaseData(1);
        boolean r = userService.save(user);
        if (r) {
            return ResultUtil.SUCCESS;
        }
        return ResultUtil.FAIL;
    }
}
